#ifndef UTIL_HISTOGRAM_H_
#define UTIL_HISTOGRAM_H_
#include <string>

namespace fermat {

class Histogram {
 public:
  Histogram() { }
  ~Histogram() { }

  void clear();
  void add(double value);
  void merge(const Histogram& other);

  std::string toString() const;
  double median() const;
  double percentile(double p) const;
  double average() const;
  double standardDeviation() const;
  
 private:
  double _min;
  double _max;
  double _num;
  double _sum;
  double _sum_squares;

  enum { kNumBuckets = 154 };
  static const double kBucketLimit[kNumBuckets];
  double _buckets[kNumBuckets];


};
}
#endif
